﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculator
{
    public partial class Form1 : Form
    {
        private Button[,] _buttons;

        private int _rows = 10,
                    _columns = 10;

        public Form1()
        {
            InitializeComponent();

            //MyInitialize();
        }

        private void MyInitialize()
        {
            _buttons = new Button[_columns,_rows];
            for (int i = 0; i < _columns; i++)
                for (int j = 0; j < _rows; j++)
                {
                    _buttons[i, j] = new Button();
                }
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.tableLayoutPanel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Dock = System.Windows.Forms.DockStyle.Top;
            this.textBox1.Location = new System.Drawing.Point(0, 0);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(352, 20);
            this.textBox1.TabIndex = 0;
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = _columns;

            for (int i = 0; i < _columns; i++)
                this.tableLayoutPanel1.ColumnStyles.Add(
                    new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0f/_columns));
            for (int i = 0; i < _columns; i++)
                for (int j = 0; j < _rows; j++)
                {
                    this.tableLayoutPanel1.Controls.Add(_buttons[i, j], i, j);
                }

            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 20);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = _rows;
            for (int i = 0; i < _rows; i++)
                this.tableLayoutPanel1.RowStyles.Add(
                    new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F/_rows));

            //    this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(352, 354);
            this.tableLayoutPanel1.TabIndex = 1;
            // 
            // button1
            // 
            foreach (var button in _buttons)
            {
                button.Dock = System.Windows.Forms.DockStyle.Fill;
            }
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(352, 374);
            this.Controls.Add(this.tableLayoutPanel1);
            this.Controls.Add(this.textBox1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.tableLayoutPanel1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text += (sender as Button).Text;
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            textBox1.Text = this.Size.ToString();
        }

        private void button29_Click(object sender, EventArgs e)
        {
            richTextBox1.AppendText("1");
        }
    }
}
